FROM ac2-registry.cn-hangzhou.cr.aliyuncs.com/ac2/base:ubuntu22.04

# 设置非交互式安装
ENV DEBIAN_FRONTEND=noninteractive

# 预配置 dpkg，使其自动选择保持当前配置
RUN echo 'Dpkg::Options::="--force-confold";' > /etc/apt/apt.conf.d/local

# 安装依赖
RUN apt-get update && \
    apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install -y \
    libstdc++6 \
    libc6 \
    python3 \
    python3-pip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# 创建 python 符号链接
RUN ln -sf /usr/bin/python3 /usr/bin/python

# 设置工作目录
WORKDIR /app

# 复制应用程序文件到容器中
COPY apiserver.py /app/
COPY templates /app/templates/
COPY llama-cli /app/

# 安装依赖
RUN pip install --no-cache-dir flask -i https://pypi.tuna.tsinghua.edu.cn/simple

# 暴露端口 5000
EXPOSE 5000

# 运行应用
CMD ["python", "apiserver.py", "--llama-cli-path", "/app/llama-cli", "--model-path", "/app/models/qwen2-1_5b-instruct-q3_k_m.gguf"]